<template>
  <div>
 <div v-if="userInfo!=undefined" style="width: 100%;border-radius: 5px;border: 1px solid rgb(230,230,230);padding: 20px 20px;margin-bottom: 20px;">
    <div style="line-height: 30px;padding-bottom: 10px;">
        考生信息
    </div>
    <div style="line-height: 30px;">
      姓名：{{ userInfo.name }}
    </div>
    <div style="line-height: 30px;">
      分数：{{ userInfo.score }}
    </div>
    <div style="line-height: 30px;">
      位次：{{ userInfo.ranking }}
    </div>
    <div style="line-height: 30px;">
      省份：{{ userInfo.province }}
    </div>
    <div style="line-height: 30px;">
      科目：{{ getSubjectString() }}
    </div>
    <a-button style="margin-top: 10px;" type="primary" @click="changePageToUserCenter">用户中心</a-button>
 </div>
<div v-if="userInfo==undefined" style="width: 100%;border-radius: 5px;margin-bottom: 20px;background-color: rgba(255,0,0,0.1);padding: 20px 20px;text-align: center;">
  <icon-info-circle />请先登录以使用查询功能和填报志愿<br>
  <a-button @click="changePageToLoginPage" style="margin-top: 10px;" type="primary">登录</a-button>
</div>
  </div>
</template>

<script>
import router from '@/utils/router';

export default{
  data(){
    return{
      
    }
  },
  mounted(){

  },
  methods:{
    changePageToUserCenter(){
      router.push('/userCenter');
    },
    changePageToLoginPage(){
      router.push('/login');
    },
    getSubjectString(){
      if(this.userInfo.subjects.slice(0,1)=='1'){
                let re = '';
                for(let i=1;i<=3;i++){
                  if(i!=1){
                    re+='、'
                  }
                  switch (this.userInfo.subjects.slice(i,i+1)) {
                    case '1':
                      re+='物理';
                      break;
                    case '2':
                      re+='化学';
                      break;
                    case '3':
                      re+='生物';
                      break;
                    case '4':
                      re+='政治';
                      break;
                    case '5':
                      re+='历史';
                      break;
                    case '6':
                      re+='地理';
                      break;
                  }
                }
                return re;
      }
      if(this.userInfo.subjects.slice(0,1)=='2'){
                let re = '';
                for(let i=1;i<=3;i++){
                  if(i!=1){
                    re+='、'
                  }
                  switch (this.userInfo.subjects.slice(i,i+1)) {
                    case '1':
                      re+='化学';
                      break;
                    case '2':
                      re+='生物';
                      break;
                    case '3':
                      re+='政治';
                      break;
                    case '4':
                      re+='地理';
                      break;
                    case '5':
                      re+='物理';
                      break;
                    case '6':
                      re+='历史';
                      break;
                  }
                }
                return re;
      }
      if(this.userInfo.subjects.slice(0,1)=='3'){
        return this.userInfo.subjects.slice(1,2)=='1'?'理科':'文科';
      }
    }
  },
  props:{
    userInfo:{
        type:Object
    }
  },
}
</script>

<style scoped>

</style>